/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import DAO.ConnectUnit;
import GUI.Menu.JIFBanHang;
import GUI.Menu.JIFBaoCao;
import GUI.Menu.JIFDanhMuc;
import GUI.Menu.JIFHeThong;
import GUI.Menu.JIFKhoHang;
import GUI.Menu.JIFThuChi;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.net.URL;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.DesktopPaneUI;


/**
 *
 * @author 10520_000
 */
public class jframeMain extends javax.swing.JFrame implements ActionListener{

    AutoSuggest _tenKhach = null;
    public jframeMain() {
       
        this.setIconImage(Toolkit.getDefaultToolkit().getImage("src/Image/login.png"));
        
        
        initComponents();
              
        
        //Make dragging a little faster but perhaps uglier.        
         setExtendedState(MAXIMIZED_BOTH);
         
         // Set giao dien cac ChildFrom
         desktop.setUI(new DesktopPaneUI() {
             @Override
        public void installUI(JComponent c) {
            // TODO Auto-generated method stub
            try {
                //UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");
                //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                UIManager.setLookAndFeel("com.jtattoo.plaf.hifi.HiFiLookAndFeel");
                //UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel");
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) {
            }
            super.installUI(c);
        }          
        });
        
 
        JIFDanhMuc frame;
        
        try {
            frame = new JIFDanhMuc();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
                       
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    // Set kich thuoc cac tab menu
    private void setSize(JInternalFrame frm){
        frm.setSize(283, 270);
    }
   
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jInternalFrame1 = new javax.swing.JInternalFrame();
        desktopCN = new javax.swing.JDesktopPane();
        desktop = new javax.swing.JDesktopPane();
        jPanelTab = new javax.swing.JPanel();
        jButtonKhoHang = new javax.swing.JButton();
        jButtonBanHang = new javax.swing.JButton();
        jButtonThuChi = new javax.swing.JButton();
        jButtonBaoCao = new javax.swing.JButton();
        jButtonHeThong = new javax.swing.JButton();
        jButtonDanhMuc = new javax.swing.JButton();
        jButtonLogout = new javax.swing.JButton();
        jButtonExit = new javax.swing.JButton();

        jInternalFrame1.setVisible(true);

        javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
        jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
        jInternalFrame1Layout.setHorizontalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jInternalFrame1Layout.setVerticalGroup(
            jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("PHẦN MỀM QUẢN LÝ NHÀ SÁCH");
        setLocationByPlatform(true);
        setPreferredSize(new java.awt.Dimension(800, 600));

        desktopCN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        desktop.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jPanelTab.setBackground(new java.awt.Color(51, 51, 51));
        jPanelTab.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanelTab.setForeground(new java.awt.Color(255, 255, 255));

        jButtonKhoHang.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/home1.png"))); // NOI18N
        jButtonKhoHang.setText("Quản lý kho hàng");
        jButtonKhoHang.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonKhoHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonKhoHangActionPerformed(evt);
            }
        });

        jButtonBanHang.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/ban.png"))); // NOI18N
        jButtonBanHang.setText("Quản lý bán hàng");
        jButtonBanHang.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonBanHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBanHangActionPerformed(evt);
            }
        });

        jButtonThuChi.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/chi.png"))); // NOI18N
        jButtonThuChi.setText("Quản lý thu chi");
        jButtonThuChi.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonThuChi.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonThuChiActionPerformed(evt);
            }
        });

        jButtonBaoCao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/report4.png"))); // NOI18N
        jButtonBaoCao.setText("Báo cáo");
        jButtonBaoCao.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonBaoCao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBaoCaoActionPerformed(evt);
            }
        });

        jButtonHeThong.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/cp.png"))); // NOI18N
        jButtonHeThong.setText("Hệ thống");
        jButtonHeThong.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonHeThong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHeThongActionPerformed(evt);
            }
        });

        jButtonDanhMuc.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/list1.png"))); // NOI18N
        jButtonDanhMuc.setText("Liệt kê danh mục");
        jButtonDanhMuc.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jButtonDanhMuc.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonDanhMucActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelTabLayout = new javax.swing.GroupLayout(jPanelTab);
        jPanelTab.setLayout(jPanelTabLayout);
        jPanelTabLayout.setHorizontalGroup(
            jPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTabLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonKhoHang, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                    .addComponent(jButtonBanHang, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonThuChi, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonBaoCao, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonHeThong, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButtonDanhMuc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelTabLayout.setVerticalGroup(
            jPanelTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTabLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButtonDanhMuc, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonKhoHang, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBanHang, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonThuChi, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonBaoCao, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonHeThong, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButtonLogout.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/logout.png"))); // NOI18N
        jButtonLogout.setText("Đăng xuất");
        jButtonLogout.setToolTipText("");
        jButtonLogout.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLogoutActionPerformed(evt);
            }
        });

        jButtonExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/close1.png"))); // NOI18N
        jButtonExit.setText("Thoát");
        jButtonExit.setToolTipText("");
        jButtonExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExitActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonLogout, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonExit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 282, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jPanelTab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(desktopCN, javax.swing.GroupLayout.DEFAULT_SIZE, 621, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(desktopCN, javax.swing.GroupLayout.PREFERRED_SIZE, 688, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(desktop, javax.swing.GroupLayout.PREFERRED_SIZE, 271, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanelTab, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonExit)
                            .addComponent(jButtonLogout, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(20, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonDanhMucActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDanhMucActionPerformed
        // TODO add your handling code here:
        JIFDanhMuc frame;
        try {
            frame = new JIFDanhMuc();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonDanhMucActionPerformed

    private void jButtonKhoHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonKhoHangActionPerformed
        // TODO add your handling code here:
        JIFKhoHang frame;
        try {
            frame = new JIFKhoHang();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonKhoHangActionPerformed

    private void jButtonBanHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBanHangActionPerformed
        // TODO add your handling code here:
        JIFBanHang frame;
        try {
            frame = new JIFBanHang();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonBanHangActionPerformed

    private void jButtonThuChiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonThuChiActionPerformed
        // TODO add your handling code here:
        JIFThuChi frame;
        try {
            frame = new JIFThuChi();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonThuChiActionPerformed

    private void jButtonBaoCaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBaoCaoActionPerformed
        // TODO add your handling code here:
        JIFBaoCao frame;
        try {
            frame = new JIFBaoCao();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonBaoCaoActionPerformed

    private void jButtonHeThongActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHeThongActionPerformed
        // TODO add your handling code here:
        JIFHeThong frame;
        try {
            frame = new JIFHeThong();
            setSize(frame);
            frame.setVisible(true);
            frame.setDesktop(desktopCN);
            desktop.add(frame);
            frame.setSelected(true);
            
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JIFDanhMuc.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButtonHeThongActionPerformed

    private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExitActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jButtonExitActionPerformed

    private void jButtonLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLogoutActionPerformed
        
    }//GEN-LAST:event_jButtonLogoutActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) 
    {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try 
        {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) 
            {
                if ("Nimbus".equals(info.getName())) 
                {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    //javax.swing.UIManager.setLookAndFeel("com.jtattoo.plaf.bernstein.BernsteinLookAndFeel");
                    break;
                }
            }
        }
        catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) 
        {
            
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() 
        {
            @Override
            public void run() {
                new jframeMain().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JDesktopPane desktopCN;
    private javax.swing.JButton jButtonBanHang;
    private javax.swing.JButton jButtonBaoCao;
    private javax.swing.JButton jButtonDanhMuc;
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonHeThong;
    private javax.swing.JButton jButtonKhoHang;
    private javax.swing.JButton jButtonLogout;
    private javax.swing.JButton jButtonThuChi;
    private javax.swing.JInternalFrame jInternalFrame1;
    private javax.swing.JPanel jPanelTab;
    // End of variables declaration//GEN-END:variables
    
     

    @Override
    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}
